<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>WebSocket Demo</title>
    <script>
        var ws = new WebSocket('ws://127.0.0.1:8889');

        ws.onopen = function () {
            console.log('WebSocket 连接已经建立');
            ws.send('Hello, I am WebSocket Client1');
        };

        ws.onmessage = function (event) {
            console.log('收到服务器消息：', event.data);
        };

        ws.onerror = function (event) {
            console.error('WebSocket 连接出现错误：', event);
        };

        ws.onclose = function () {
            console.log('WebSocket 连接已经关闭');
        };
    </script>
</head>
<body>
<h1>WebSocket Demo</h1>
</body>
</html>